#include "multigetprofilerequest.h"
#include "multigetprofileresponse.h"
#include <QUrl>


MultiGetProfileRequest::MultiGetProfileRequest(const qint64& userId,
                                               const QString &sessionKey)
    : Network::GetJSONRequest(),
    m_response(new MultiGetProfileResponse()),
    m_sessionKey(sessionKey)
{
    m_listUserId.push_back(userId);
}


MultiGetProfileRequest::MultiGetProfileRequest(const std::vector<qint64>& listUserId,
                                               const QString &sessionKey,
                                               const qint64 idx,
                                               const qint64 count)
    :Network::GetJSONRequest(),
    m_response(new MultiGetProfileResponse()),
    m_listUserId(listUserId),
    m_sessionKey(sessionKey),
    m_idx(idx),
    m_count(count)
{

}


MultiGetProfileRequest::~MultiGetProfileRequest()
{
    delete m_response;
    m_response = 0;
}


Network::JSONResponse &MultiGetProfileRequest::jsonResponse()
{
    return *m_response;
}


const Network::JSONResponse &MultiGetProfileRequest::jsonResponse() const
{
    return *m_response;
}


QUrl MultiGetProfileRequest::url() const
{
    QString paramUserId("");
    if(m_listUserId.empty()){
        return QUrl("");
    }

    for( int i = 0; i< m_listUserId.size(); ++i){
        paramUserId.append(QString::number(m_listUserId.at(i)));
        paramUserId.append(",");
    }
    QString url = QString("http://mapi2.me.zing.vn/frs/mapi2/user?method=user.getinfo&uids=%1&session_key=%2&fields=userid,username,displayname,gender,email,profile_url,dob")
            .arg(paramUserId).arg(m_sessionKey);
    return QUrl(url);
}
